package org.codeminer.parts.server.actions;

/*
 * Copyright (C) 2013 Daniel Wasilew <daniel.wasilew@codeminer.org>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * Generated ActionFactory.
 * WARNING! Do NOT modify this class
 * It is always regenerated by the Specparser.
 * All your changes will be lost the next time it is executed!
 **/
public final class ActionFactory {

    public static Action create(ActionContext context, ActionProperties actionProperties) throws ActionCreationException {
        String actionName = actionProperties.getActionName();
        try{
            if ("AddSongToPlaylist".equals(actionName)) {
                Long param0 = actionProperties.getLongParameter("songId");
                Long param1 = actionProperties.getLongParameter("playlistId");

                return new AddSongToPlaylist(context, param0, param1);
            }
            if ("CreatePlaylist".equals(actionName)) {
                String param0 = actionProperties.getParameter("name");
                Boolean param1 = actionProperties.getBooleanParameter("createGlobal");

                return new CreatePlaylist(context, param0, param1);
            }
            if ("GetAllPlaylists".equals(actionName)) {

                return new GetAllPlaylists(context);
            }
            if ("DeletePlayer".equals(actionName)) {
                Long param0 = actionProperties.getLongParameter("playerId");

                return new DeletePlayer(context, param0);
            }
            if ("GetPlayerInfo".equals(actionName)) {
                Long param0 = actionProperties.getLongParameter("playerId");

                return new GetPlayerInfo(context, param0);
            }
            if ("GetAllPlayers".equals(actionName)) {

                return new GetAllPlayers(context);
            }
            if ("CreatePlayer".equals(actionName)) {
                String param0 = actionProperties.getParameter("playerName");

                return new CreatePlayer(context, param0);
            }
            if ("EditPlayer".equals(actionName)) {
                Long param0 = actionProperties.getLongParameter("playerId");
                String param1 = actionProperties.getParameter("name");

                return new EditPlayer(context, param0, param1);
            }
            if ("Login".equals(actionName)) {
                String param0 = actionProperties.getParameter("userName");
                String param1 = actionProperties.getParameter("passHash");

                return new Login(context, param0, param1);
            }
            if ("GetAllDevices".equals(actionName)) {

                return new GetAllDevices(context);
            }
            if ("DeleteDevice".equals(actionName)) {
                Long param0 = actionProperties.getLongParameter("deviceId");

                return new DeleteDevice(context, param0);
            }
            if ("ConnectDevice".equals(actionName)) {
                String param0 = actionProperties.getParameter("name");
                Long param1 = actionProperties.getLongParameter("playerId");
                Long param2 = actionProperties.getLongParameter("deviceId");

                return new ConnectDevice(context, param0, param1, param2);
            }
            if ("DisconnectDevice".equals(actionName)) {
                Long param0 = actionProperties.getLongParameter("playerId");
                Long param1 = actionProperties.getLongParameter("deviceId");

                return new DisconnectDevice(context, param0, param1);
            }
            if ("CreateDevice".equals(actionName)) {
                String param0 = actionProperties.getParameter("name");

                return new CreateDevice(context, param0);
            }
            throw new UnsupportedOperationException("Message not handled");
        } catch (Exception ex) {
            throw new ActionCreationException(ex);
        }
    }
}
